package com.home.free.entity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 用户表-状态类
 * @author gaotianjie
 */

public enum UserStatusEnum {
    /**
     * 用户状态: 5: 审核中, 10: 正常, 15: 冻结
     */
    EXAMINE(5, "审核中"),
    NORMAL(10, "正常"),
    FROZEN(15, "冻结");

    private Integer id;
    private String name;

    UserStatusEnum(Integer id, String name) {
        this.name = name;
        this.id = id;
    }

    /**
     * 普通方法
     */
    public static String getName(int index) {
        for (UserStatusEnum c : UserStatusEnum.values()) {
            if (c.getId() == index) {
                return c.name;
            }
        }
        return null;
    }

    /**
     * 获取全部枚举
     * @return
     */
    public static List<Map<String, Object>> getList() {
        List<Map<String, Object>> result = new ArrayList<>();
        UserStatusEnum[] enums = UserStatusEnum.values();

        for (UserStatusEnum item : enums) {
            Map<String, Object> map = new HashMap<>();
            map.put("id", item.getId());
            map.put("name", item.name());
            result.add(map);
        }

        return result;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
